/*
 *  GGB - Gelin's Guest Book.
 *  Copyright (C) 2006-2009  Denis Nelubin aka Gelin
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  http://gelin.ru
 *  mailto:den@gelin.ru
 *
 *  Description:    Tables creating script template.
 *
 *  History:
 *  2006-06-21  Gelin   Initially created.
 *  2007-01-20  Gelin   Modified for new ban strategy.
 *  2009-10-14  Gelin   Added approve_time column
 *
 */

CREATE TABLE %dbTablePrefix%message (
    id INT NOT NULL AUTO_INCREMENT,
    post_time INT DEFAULT NULL,
    approve_time INT DEFAULT NULL,
    delete_time INT DEFAULT NULL,
    reply_time INT DEFAULT NULL,
    name VARCHAR(255) DEFAULT NULL,
    email VARCHAR(255) DEFAULT NULL,
    url VARCHAR(255) DEFAULT NULL,
    message TEXT DEFAULT NULL,
    reply TEXT DEFAULT NULL,
    PRIMARY KEY (id),
    INDEX (post_time)
);

CREATE TABLE %dbTablePrefix%message_header (
    message_id INT NOT NULL REFERENCES %dbTablePrefix%message(id),
    header_id INT NOT NULL,
    value VARCHAR(255),
    INDEX (message_id)
);

CREATE TABLE %dbTablePrefix%ban_rule (
    id INT NOT NULL AUTO_INCREMENT,
    header_id INT NOT NULL,
    value VARCHAR(255) NOT NULL,
    create_time INT DEFAULT NULL,
    PRIMARY KEY (id, header_id),
    INDEX (id),
    INDEX (header_id, value)
);
